/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package eit.dao.impl;

import eit.dao.rowmapper.TagRowMapper;
import eit.model.Tag;
import eit.dao.TagDAO;
import java.util.ArrayList;
import java.sql.Types ;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;

/**
 *
 * @author acoustic
 */

@Repository
public class TagDAOImpl implements TagDAO
{
	@Autowired
	private JdbcTemplate tagJDBCTemplate ;

	@Override
	public void insert(Tag _Item)
	{
		throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
	}

	@Override
	public void update(Tag _Item)
	{
		throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
	}

	@Override
	public void delete(Tag _Item)
	{
		throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
	}

	@Override
	public Tag get(int _ID)
	{
		throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
	}
	

	@Override
	public ArrayList<Tag> getAll()
	{
		throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
	}
	
	
	@Override
	public ArrayList<Tag> getTagsByIssueID(int _issueID)
	{
		String sqlQuery = 
				"SELECT T.* "
				+ "FROM rlt_issue_tag R "
				+ "INNER JOIN tag T on R.TagID = T.ID "
				+ "WHERE R.IssueID = ?" ;
		
		ArrayList<Tag> tagList = 
				(ArrayList<Tag>)
				//this.tagJDBCTemplate.queryForList(sqlQuery, new Object[]{_issueID}, Types.ARRAY, Tag.class) ;
				this.tagJDBCTemplate.query(sqlQuery, new Object[]{_issueID}, new TagRowMapper() );
		
		return tagList ;
	}
}
